<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>allSettled</title>
</head>

<body>

</body>
<script>
    // allSettled 拿到正确和错误的所有数据，promise错误没处理的也能收到，再过滤一下就能拿到正确的数据
    const p1 = new Promise((resolve, reject) => {
        reject("ok")
    })
    const p2 = new Promise((resolve, reject) => {
        resolve("failed")
    })
    Promise.allSettled([p1, p2]).then(results => {
        let success = results.filter(user => {
            return user.status == "fulfilled"
        })

        // console.log(results)
        console.log(success)
    })
</script>

</html>